package com.example.Controller;

import com.example.Model.JudegeData;
import com.example.Model.JudegeResult;
import com.example.Server.JudgeServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/*
* 这个控制器用来作为判题端
 */
@CrossOrigin("*")
@RestController
public class JudgeController {

    @Autowired
    JudgeServer Server;

    @PostMapping("/Judege")
    /*
    * 开始评测
     */
    public JudegeResult Judege(@RequestBody JudegeData data){
        JudegeResult res= Server.Judge(data.UserCode,Integer.valueOf(data.qid),data.LuganType);
        res.Code="10001";
        if (res.JundgeResType.equals("Accepted.AC"))
            res.Code="10000";
        return res;
    }



}
